#!/usr/bin/env python
#-*- coding:utf-8 -*-
# author:Vergil
# datetime:2019/4/7 19:30
# software: PyCharm
from django.utils.deprecation import MiddlewareMixin

class OnlineStatusMiddleware(MiddlewareMixin):
    """
    用户在线状态消息中间件
    """

    def process_request(self, request):
        # 判断用户是否为登录状态,如果在线,则更新session过期时间
        if request.user.is_authenticated:
            request.session.set_expiry(600)

        return None